# name : LOCF using retain, except baseline
# key : locf.retain.except.baseline
# contributor: Shuguang Sun
# --
length ${1:dtype} \$15;
retain ${2:retain};
set lab;
by ${3:usubjid} ${4:avisitn};
if first.$3 and $4 ne 0 then $2 = .;
if ${5:aval} ne . and $4 ne 0 then $2 = $5;
if $5 = . then do;
  ${6:avallocf} = $2;
  $1 = 'LOCF';
end;
else $6 = $5;